﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace ExamSharedClasses {
    /// <summary>
    /// (k) Der Fragentyp, der einen Textstring als Antwort hat und
    /// der User entsprechend den Antworttext korrekt eingeben muß.
    /// </summary>
    [Serializable()]
    public class QuestionTypeText : Question {
        new public const string TABLENAME = "question_type_text";
        public const string QUESTION_AUTHOR = "question_autor";
        public const string QUESTION_BODY = "question_body";
        public const string QUESTION_RIGHT_ANSWER = "question_right_answer";
        public const string QUESTION_ACTIVE = "question_active";

        public User QuestionAuthor { get; set; }
        public string QuestionBody { get; set; }
        public string QuestionRightAnswer { get; set; }
        public bool QuestionActive { get; set; }

        public QuestionTypeText()
            : base() {
            QuestionTypeObject = "text";
            QuestionAuthor = new User();
            QuestionBody = "";
            QuestionRightAnswer = "";
            QuestionActive = true;
        }
        public QuestionTypeText( Question question )
            : base( question ) {
            QuestionTypeObject = "text";
            QuestionAuthor = new User();
            QuestionBody = "";
            QuestionRightAnswer = "";
            QuestionActive = true;
        }

        public override string ToString() {
            StringBuilder sb = new StringBuilder( base.ToString() );
            sb.Append( "Author: " + QuestionAuthor.UserEmail + ")\n" );
            sb.Append( "Frage: " + QuestionBody.ToString() + '\n' );
            //besser nicht...sb.Append( "richtige Antwort: " + QuestionRightAnswer + '\n' );
            return sb.ToString();
        }
        public override string ToMoreDetailedString() {
            StringBuilder sb = new StringBuilder( );
            sb.Append( "richtige Antwort: " + QuestionRightAnswer + '\n' );
            sb.Append( "im Umlauf?: " + QuestionActive.ToString() + '\n' );
            return ToString() + sb.ToString();
        }
    }
}